﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NENAData.Events;
using Telerik.Web.UI;

namespace Events
{
    public partial class AJAX : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                LoadEvents();
        }

        private void LoadEvents()
        {
            var item = new RadListBoxItem();

            //item.("Item Text");
            radListBoxMembership.Items.Add(new RadListBoxItem("NENA Member", "true"));
            radListBoxMembership.Items.Add(new RadListBoxItem("NENA Non-Member", "false"));
            radListBoxMembership.DataBind();
        }

        protected void SelectMembership(object sender, EventArgs e)
        {
            var o = new NENAData.Events.List();
            //RadGrid1.MasterTableView = o.GetAll(true, NENAData.Transactions.TransactionList.Transactions.ConferenceRegina2011);
            //RadGrid1.DataSource = o.GetAll(true, NENAData.Transactions.TransactionList.Transactions.ConferenceRegina2011);
            var oSelection = Convert.ToBoolean(radListBoxMembership.SelectedItem.Value.ToString());

            GridView1.DataSource = o.GetAll(oSelection, NENAData.Transactions.TransactionList.Transactions.ConferenceRegina2012);
            GridView1.DataBind();
            //RadGrid1.DataSource 
            //RadGrid1.DataBind();                
        }

        protected void EventsDataGrid_SelectedIndexChange(object sender, EventArgs e)
        {
            //Response.Write(GridView1.SelectedValue.ToString());
            GridViewRow row = GridView1.SelectedRow;
            //Response.Write("selected value = " + Convert.ToString(row.Cells[1].Text));
            var oSlotSession = new NENAData.Events.SlotSession();
            int intEvent = Convert.ToInt32(row.Cells[1].Text);
            GridViewSlotSessions0.DataSource = oSlotSession.GetSessionsByEvent(intEvent);
            GridViewSlotSessions0.DataBind();

        }

        protected void SelectSessionSlots(object sender, EventArgs e)
        {
            var o = new NENAData.Events.Slots();
            //GridView1.SelectedRow.DataItem[]
            //GridViewSlotSessions.DataSource = o.GetAll(GridView1.SelectedIndex
        }

    }
}